package day_2022_9_to_12.Day;

/**
 * @author haomin
 * @date 2022/10/24 22:33
 **/
public class Day51_1_Num915_PartitionDisjoint {
    class Solution {
        public int partitionDisjoint(int[] A) {
            if (A == null || A.length == 0) {
                return 0;
            }

            int leftMax = A[0];
            int max = A[0];
            int index = 0;

            for (int i = 0; i < A.length; i++) {
                max = Math.max(max, A[i]);
                if(A[i] < leftMax) {
                    leftMax = max;
                    index = i;
                }
            }

            return index + 1;
        }
    }
}